//
//  FWCTabBarViewController.swift
//  微博项目001
//
//  Created by 樊武超 on 16/4/6.
//  Copyright © 2016年 樊武超. All rights reserved.
//

import UIKit

class FWCTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tab=FWCTabBar()

        setValue(tab, forKey: "tabBar")
        
        tab.butn.addTarget(self, action:"btnDidClick", forControlEvents: UIControlEvents.TouchUpInside)
        
        addChildViewControllers()
    }
    @objc private func btnDidClick(){
    
    print("点击了butn")
    
    }
   private func addChildViewControllers() {
    addChildViewController(FWCHomeTableViewController(), title: "首页", imageName: "tabbar_home")
    addChildViewController(FWCMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
    addChildViewController(FWCDiscoverTableViewController(), title: "搜索", imageName: "tabbar_discover")
    addChildViewController(FWCProfileTableViewController(), title: "我", imageName: "tabbar_profile")
    
    }
    private func addChildViewController(childController: UIViewController,title:String,imageName:String) {
        childController.navigationItem.title=title
        childController.tabBarItem.title=title
//        tabBar.tintColor=UIColor.orangeColor()
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()],forState: .Selected)
        
        childController.tabBarItem.image=UIImage(named: imageName)
        childController.tabBarItem.selectedImage=UIImage(named: imageName+"_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        let nav=FWCNavViewController(rootViewController: childController)
        
            addChildViewController(nav)
     }
}
